package com.example.demo.Controller;

import com.example.demo.Dto.AiChatAssistantDto;
import com.example.demo.Dto.AiOrderQueryDto;
import com.example.demo.Service.AiService;

import com.example.demo.VO.OrderInfoVo;
import com.example.demo.result.ResponseResult;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

import java.util.List;

@RestController
@RequestMapping("/ai")
@RequiredArgsConstructor
public class AiController {
    private final AiService aiService;
    /**
     * 智能订单查询接口
     * @param aiOrderQueryDto
     * @return
     */
    @PostMapping("/orders/query")
    public ResponseResult query(@RequestBody AiOrderQueryDto aiOrderQueryDto){
        List<OrderInfoVo> orders = aiService.getOrders(aiOrderQueryDto);
        return  new ResponseResult().ok(200,"查询成功",orders);
    }
    /**
     * 智能聊天接口
     * @param aiOrderQueryDto
     * @return
     */
    @PostMapping("/chat/assistant")
    public ResponseResult Chat(@RequestBody AiChatAssistantDto aiOrderQueryDto){
        if (aiOrderQueryDto.getChatContent()==null){
            throw new RuntimeException("请输入内容");
        }
        String chat = aiService.getChat(aiOrderQueryDto.getChatContent());
        return new ResponseResult().ok(200,"查询成功",chat);
    }
}
